<table class="assign_table" cellspacing="0" cellpadding="0">
    <thead>
        <tr>
            <th><?php echo __('Program')?></th>
            <th><?php echo __('Start Program Date')?></th>
            <th><?php echo __('Assignment status')?></th>
            <th><?php echo __('Teacher Assigned')?></th>
            <th><?php echo __('download_approval_form')?></th>
        </tr>
    </thead>
    <tbody>
        <?php if(!count($data)){?>
        <tr class="no_data">
            <td colspan="4">
                <?php echo __('No programs found')?>
            </td>
        </tr>
        <?php }else{ ?>
            <?php
            $i = 0;
            foreach($data as $row){ ?>
            <?php $j = 1 ?>
            <?php $assign_arr = LinkTeacherProgramTable::getInstance()->getOrCreateAssignRecord($row['id'], $school_intg_id, true); ?>
                <?php foreach($assign_arr as $rec){ ?>
                    <tr id="assignment_row_<?php echo $row['id'].$j ?>" class="<?php echo ($i%2==1?'bg_color':'').(' row_status_'.(!empty($rec['assign_status'])  && isset($rec['Teacher']) ? $rec['assign_status'] : '0'));?>">
                        <td>
                            <?php echo $row['name'] ?>
                            <br/>
                            <?php echo __('Program code').' '.$row['program_code']?>
                            <br/>
                            [<a class="card_link" href="#" onclick="window.open('<?php echo url_for('program/card?id='.$row['id'])?>', 'programWindow', 'width=600,height=600,scrollbars=true')"><?php echo __('Program card')?></a>]
                        </td>
                        <td>
                          <?php echo $row['start_date']?>   
                        </td>
                        <td class="assignment_status_cell">
                            <?php if(!isset($rec['Teacher'])){?>
                              <?php echo __('No assignment yet')?>
                            <?php }else{ ?>
                                <span id="assigned_to_program_<?php echo $row['id'].$j ?>">
                                      <?php                              
                                        echo __(LinkTeacherProgramTable::$assign_status_arr[$rec['assign_status']]);
                                      ?>
                                </span>
                            <?php } ?>
                        </td>
                        <td class="assignment_status">
                            <div id="assign_cont_<?php echo $row['id'].$j; ?>">
                            <?php
                            include_partial('assignCell', array('teachers'=>$my_teachers, 
                                                                'program_id'  => $row['id'],
                                                                'assign_index'  => $j,
                                                                'school_intg_id'  => $school_intg_id,
                                                                'assign_stat' => $rec['assign_status'],
                                                                'assigned_teacher'=>  isset ($rec['Teacher']) ? $rec['Teacher'] : null ));?>
                            </div>
                        </td>
                        <td id="download" program_id="<?php echo $row['id'].$j ?>">
                            <?php if(isset($rec['teacher_id'])) { ?>
                                <a onclick="js_approve(this)" href="<?php echo url_for('assignment/downloadApproval?teacher_id='.($rec['teacher_id'] ? $rec['teacher_id'] : '-1').'&program_id='.$row['id']) ?>"><?php echo __('Download Approval Document') ?></a>
                            <?php } ?>                        
                        </td>
                    </tr>
                <?php $j++; } ?>
                    <tr><td colspan="5" style="text-align:center;">----------------------------------------------------------------------------------------------------</td></tr>
            <?php $i++; }?>
        <?php }?>        
    </tbody>
</table>
<script>
function js_approve(elem){
    _tr_ =  $(elem).parents('tr:eq(0)');
    _tr_.removeClass('row_status_1').addClass('row_status_2');
    _tr_.find('.assignment_status_cell span').html('<?php echo __('Approved') ?>');
}
</script>